<?php

/**
 * Category filter form base class.
 *
 * @package    www.furr.sk
 * @subpackage filter
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormFilterGeneratedTemplate.php 24171 2009-11-19 16:37:50Z Kris.Wallsmith $
 */
abstract class BaseCategoryFormFilter extends BaseFormFilterDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'parent'  => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Category'), 'add_empty' => true)),
      'visible' => new sfWidgetFormChoice(array('choices' => array('' => 'yes or no', 1 => 'yes', 0 => 'no'))),
      'extern'  => new sfWidgetFormChoice(array('choices' => array('' => 'yes or no', 1 => 'yes', 0 => 'no'))),
      'menu'    => new sfWidgetFormFilterInput(),
      'ord'     => new sfWidgetFormFilterInput(),
    ));

    $this->setValidators(array(
      'parent'  => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('Category'), 'column' => 'id')),
      'visible' => new sfValidatorChoice(array('required' => false, 'choices' => array('', 1, 0))),
      'extern'  => new sfValidatorChoice(array('required' => false, 'choices' => array('', 1, 0))),
      'menu'    => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'ord'     => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
    ));

    $this->widgetSchema->setNameFormat('category_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Category';
  }

  public function getFields()
  {
    return array(
      'id'      => 'Number',
      'parent'  => 'ForeignKey',
      'visible' => 'Boolean',
      'extern'  => 'Boolean',
      'menu'    => 'Number',
      'ord'     => 'Number',
    );
  }
}
